package com.dmw.util;

import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 邮件发送接口的实现
 * @author hduser
 *
 */
@Component
public class MailUtil {

	@Resource
	private MailSender mailSender;

	/**
	 * 发送邮件
	 */
	public void send(String mailTo, String mailFrom, String mailSubject, String mailText) {

		//邮件对象
		SimpleMailMessage mailMessage = new SimpleMailMessage();

		//设置发件人邮箱
		mailMessage.setFrom(mailFrom);
		//设置邮件主题
		mailMessage.setSubject(mailSubject);
		//设置收件人邮箱
		mailMessage.setTo(mailTo);
		//设置邮件内容
		mailMessage.setText(mailText);

		//发送邮件
		mailSender.send(mailMessage);
	}
}
